import tkinter as tk
from tkinter import messagebox
import random

# 消防员小游戏
def fireman_game():
    game = tk.Tk()
    game.title("消防员灭火游戏")

    # 创建一个简单的游戏界面
    fire = tk.Label(game, text="🔥", font=("Helvetica", 50))
    fireman = tk.Label(game, text="🚒", font=("Helvetica", 50))
    fire.place(x=200, y=100)
    fireman.place(x=50, y=200)

    # 消防员移动
    def move_fireman(event):
        if event.keysym == 'Right':
            fireman.place(x=fireman.winfo_x() + 10)
        elif event.keysym == 'Left':
            fireman.place(x=fireman.winfo_x() - 10)
        elif event.keysym == 'Up':
            fireman.place(y=fireman.winfo_y() - 10)
        elif event.keysym == 'Down':
            fireman.place(y=fireman.winfo_y() + 10)

    game.bind('<Key>', move_fireman)

    game.mainloop()

# 问题界面
def question_window():
    question = tk.Tk()
    question.title("问题")

    # 第一个问题
    tk.Label(question, text="你是否记得小时候的梦想（成为消防员）？").grid(row=0, column=0, columnspan=2)

    # 第一个问题的选项
    def answer_yes():
        question.destroy()
        fireman_game()

    def answer_no():
        question.destroy()
        career_choice_window()

    tk.Button(question, text="是", command=answer_yes).grid(row=1, column=0)
    tk.Button(question, text="不是", command=answer_no).grid(row=1, column=1)

    question.mainloop()

# 职业规划问题界面
def career_choice_window():
    career = tk.Tk()
    career.title("未来职业规划")

    # 职业规划问题
    tk.Label(career, text="你的未来职业规划是什么？").grid(row=0, column=0, columnspan=2)

    # 职业选项
    choices = ["程序员", "军人", "公务员"]
    selected_choices = []

    def select_choice(choice):
        if choice in selected_choices:
            selected_choices.remove(choice)
        else:
            selected_choices.append(choice)

    # 创建选项按钮
    for i, choice in enumerate(choices):
        tk.Radiobutton(career, text=choice, variable=tk.IntVar(), value=i, command=lambda c=choice: select_choice(c)).grid(row=i+1, column=0, sticky="w")

    # 提交按钮
    def submit_choices():
        if selected_choices:
            messagebox.showinfo("感谢", f"你选择了：{', '.join(selected_choices)}。任何选择都是光荣的！")
            firework_window()
        else:
            messagebox.showerror("错误", "请至少选择一个职业")

    tk.Button(career, text="提交", command=submit_choices).grid(row=len(choices)+1, column=0, columnspan=2)

    career.mainloop()

# 放烟火图像的窗口
def firework_window():
    firework = tk.Tk()
    firework.title("光荣的选择")

    # 显示放烟火的图像
    firework_label = tk.Label(firework, text="🎆🎇🎆", font=("Helvetica", 100))
    firework_label.pack()

    firework.mainloop()

# 登录界面
def login_window():
    login = tk.Tk()
    login.title("登录")

    # 设置背景为火箭图像
    rocket_image = tk.PhotoImage(file="rocket.png")  # 请确保图像文件与此Python文件位于同一目录中
    rocket_label = tk.Label(login, image=rocket_image)
    rocket_label.place(x=0, y=0, relwidth=1, relheight=1)

    # 用户名和密码输入
    tk.Label(login, text="用户名", bg="white").grid(row=0, column=0)
    tk.Label(login, text="密码", bg="white").grid(row=1, column=0)
    username = tk.Entry(login)
    password = tk.Entry(login, show="*")
    username.grid(row=0, column=1)
    password.grid(row=1, column=1)

    # 登录按钮
    def check_login():
        if username.get() == "邹加忠" and password.get() == "123456":
            login.destroy()
            question_window()
        else:
            messagebox.showerror("错误", "用户名或密码不正确")

    tk.Button(login, text="登录", command=check_login, bg="white").grid(row=2, column=0, columnspan=2)


